package com.hg.concurent.demo2;

import java.util.Random;
import java.util.concurrent.BlockingQueue;

/**
 * @Author: skh
 * @Date: 2019/10/17 16:44
 * @Description:
 */
public class Producer implements Runnable{

    private BlockingQueue<Integer> blockingQueue;

    public Producer(BlockingQueue blockingQueue) {
        this.blockingQueue = blockingQueue;
    }



    @Override
    public void run() {
        Random random = new Random();
        try {
            while (true) {
                int i = random.nextInt(1000);
                blockingQueue.put(i);
                System.out.println("生产者生产数据:" + i);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
